import CryptoJS from 'crypto-js';

// 加密

export function encryptAES(plaintext, keyStr = "73566da06549ebc9d4f7ae9afe628a4e") {
	try {
		const key = CryptoJS.enc.Utf8.parse(keyStr);
		const encrypted = CryptoJS.AES.encrypt(plaintext, key, {
			mode: CryptoJS.mode.ECB,
			padding: CryptoJS.pad.Pkcs7
		});
		return encrypted.ciphertext.toString(CryptoJS.enc.Hex);//转16进制
	} catch (error) {
		console.error("AES 加密失败:", error);
		return null;
	}
}

/* 
 export function encryptData(data) {
 	const input = data;
 	const aesKey = "73566da06549ebc9d4f7ae9afe628a4e";
 
 	const key = CryptoJS.enc.Utf8.parse(aesKey);
 
 	const encrypted = CryptoJS.AES.encrypt(input, key, {
 		mode: CryptoJS.mode.ECB,
 		padding: CryptoJS.pad.Pkcs7
 	});
 
 	const encryptedBase64 = encrypted.ciphertext.toString(CryptoJS.enc.Hex);
 	return encryptedBase64
 
 }
 */
export default encryptAES